package handler

import (
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	ticket "ticket_srv/proto"
	user "user_srv/proto"
)

type ServerConfig struct {
}

func ServerNewClient() *ServerConfig {
	return &ServerConfig{}
}

func Init(addr *string) *grpc.ClientConn {
	flag.Parse()
	conn, _ := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	return conn
}

func (ServerConfig) UserServer(addr *string) user.UserClient {
	init := Init(addr)
	client := user.NewUserClient(init)
	return client
}

func (ServerConfig) TicketServer(addr *string) ticket.TicketClient {
	init := Init(addr)
	client := ticket.NewTicketClient(init)
	return client
}
